<template>
  <div class="order">
    <header>
      <van-icon name="arrow-left" @click="handleBack()" size="25"/>
      <form action="/">
        <van-search
            v-model="value"
            show-action
            placeholder="请输入搜索关键词"
            @search="onSearch"
            @cancel="onCancel"
            shape="round"
        />
      </form>
    </header>
    <van-tabs v-model:active="active" color="#55a024" line-width="75px">
        <van-tab title="待支付"></van-tab>
        <van-tab title="待发货"></van-tab>
        <van-tab title="待收货"></van-tab>
        <van-tab title="待评价"></van-tab>
        <van-tab title="已完成"></van-tab>
    </van-tabs>
    <div class="top">
        <span class="top-l">订单编号:FF20221110</span>
        <span class="top-r">待付款</span>
      </div>
    <van-swipe :width="100" >
      <van-swipe-item v-for="item in store.cart" ><img :src="item.image" class="van-image__img" ></van-swipe-item>
      <template #indicator="{ active, total }">
        <div class="custom-indicator"></div>
      </template>    
    </van-swipe>
      <p class="money">共{{store.totalAmount}}件 合计: <span> ￥{{store.totalMoney}}</span></p>
      <div class="btns">
        <van-button round type="default" style="border:1px solid #55a034;margin-right: 10px;" hairline >取消订单</van-button>
        <van-button round type="success" color="#55a034" to="/desk">立即付款</van-button>
      </div>
  </div>
</template>

<script>
import { ref } from 'vue';
import useCartStore from '../../store/cart';
export default {
    setup() {
    const active = ref(0);
    const value = ref('');
    const onSearch = (val) => Toast(val);
    const onCancel = () => Toast('取消');
    const store = useCartStore();
    // console.log(store)
    return { 
        active,
        value,
        onSearch,
        onCancel, 
        store,
    };
    },
    methods: {
      handleBack() {
        this.$router.back()
      },
    },
}
</script>

<style lang="less" scoped>
    .order{
      background-color: white;
    }
    header{
        display: flex;
        justify-content: space-around;
        align-items: center;
    }
    .van-image__img{
      width: 80px;
      height: 80px;
      margin: 10px;
    }

    .top{
      margin-top: 10px;
      padding: 10px;
      display: flex;
      justify-content: space-between;
    }
    .top-l{
      font-size: 14px;
    }

    .top-r{
      font-size: 14px;
      color: red;
    }

    .money{
      font-size: 14px;
      text-align: right;
      padding-right: 20px;
      height: 30px;
      margin: 0;
      border-bottom: 1px solid #999;
    }
    .money span{
      font-size: 14px;
      color: red;
    }

    .btns{
      display: flex;
      justify-content: right;
      padding: 10px;
      border-bottom: 8px solid #999;
    }
</style>
